import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";

// https://vitejs.dev/config/
// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  plugins: [react()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  server: {
    proxy: {
      "/api": {
        target: "https://text.hangyunda.com", // 目标服务器地址
        changeOrigin: true, // 将请求头中的来源修改为目标服务器
        rewrite: (path) => path.replace(/^\/api/, ""), // 可选，重写路径
      },
    },
  },
  build: {
    // 输出目录
    outDir: "dist",
    // 启用/禁用 source maps
    sourcemap: true,
    // 启用/禁用压缩
    minify: "terser",
    rollupOptions: {
      // 入口文件
      input: "/index.html",
    },
  },
});
